package com.wsmhz.validator;

import com.wsmhz.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidatorContext;

/**
 * create by tangbj on 2018/3/25
 * 自定义验证器（请求的字段）
 */
public class ConstraintValidator implements javax.validation.ConstraintValidator<ValidConstraint,Object>{

    @Autowired
    private HelloService helloService;

    @Override
    public void initialize(ValidConstraint validConstraint) {
        System.out.println("my validator init");
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
        helloService.hello("testName");
        System.out.println(value);
        return false;
    }
}
